﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ChangeAuthor</title>
    <link rel="stylesheet" type="text/css" href="../../Content/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/default/form.css" />

    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery-1.4.4.min.js") %>'></script>

    <script type="text/javascript" language="javascript" src='<%=Url.Content("~/Scripts/jquery.easyui.min.js") %>'></script>

    <script type="text/javascript" src='<%=Url.Content("~/Scripts/jquery.form.js") %>'></script>

    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery.validate.js") %>'></script>

    <script type="text/javascript" language="javascript">
        $(function() {
            var menu = $('#roleTree');
            menu.tree({
                checkbox: true,
                url: 'LoadRoleTree',
                animate:true,
                onBeforeExpand: function(node, param) {
                    menu.tree('options').url = "";                      
                    
                }
            });
        });
        function saveRole() {
            var nodes = $('#roleTree').tree('getChecked');
            var s = '';            
            for (var i = 0; i < nodes.length; i++) {
                if (s != '') s += ',';
                s += nodes[i].id;                
            }
            var roleName = $("#userForm").children(".formTable").children("thead").children("tr").children(".headlf").text();
            $.ajax({
                url: 'SaveRole',
                type: 'Post',
                data: {
                    item:s ,
                    role: roleName                  
                },
                timeout: 20000,
                error: function(data) {
                    alert("发生未知异常，保存失败，请您稍候再试！");
                },
                success: function(data) {
                    if (data == 1) {
                        alert("保存成功！");

                    } else {
                    alert(data);
                    }
                }
            });        
        }
    </script>

</head>
<body>
    <div id="main_body">
        <form id="userForm" runat="server">
        <table class="formTable">
            <thead>
                <tr>
                    <td class="headlf">
                        <%=ViewData["rolename"] %>
                    </td>
                    <td class="headrh">
                    </td>
                </tr>
            </thead>
        </table>
        </form>
        <div id="result">
        <p style="color: #A0A7B7; padding-left:2px; font-weight:bold;">
                权限树</p>
            <ul id="roleTree">
            </ul>
            <p style="padding:12px 0px 6px 50px;">
                <input type="button" value="保存" onclick="saveRole()"/></p>
            <p style="color: #A0A7B7; padding-left: 25px;">
                权限说明：权限树中的每一项对应系统中的每一个模块，勾选表示该角色拥有该模块的权限，否则反之。"超级管理员"为系统内置，默认拥有所有权限，其权限不能修改。</p>
        </div>
    </div>
</body>
</html>
